/**
 * Created by DELL on 2017/8/18.
 */
var gulp=require("gulp");
var livereload=require("gulp-livereload");
var webserver=require("gulp-webserver");
var sass=require("gulp-ruby-sass");
var uglify=require("gulp-uglify");
//刷新页面
gulp.task("shuaxin",function () {
    return gulp.src("dest")
        .pipe(webserver({
            livereload:true,
            open:true
        }))
});
//移动目录
gulp.task("movefile",function () {
    return gulp.src("src/**/*.html")
        .pipe(gulp.dest("dest"))
});
//编译sass  gulp-ruby-scss
gulp.task("sass",function () {
    return sass("src/scss/*.scss",{
        style:"compressed"
    })
        .on("error",function (err) {
            console.log("error!!!");
            console.log(err);
        })
        .pipe(gulp.dest("dest/css"))
})
//压缩js文件   gulp-uglify
gulp.task("js",function () {
    return gulp.src("src/js/*.js")
        .pipe(uglify())
        .pipe(gulp.dest("dest/js"))
});
//监听
gulp.task("watch",function () {
    gulp.watch("src/**/*.html",["movefile"]);
    gulp.watch("src/scss/*.scss",["sass"]);
    gulp.watch("src/js/*.js",["js"]);
});

gulp.task("default",["movefile","sass","js","watch","shuaxin"])